﻿namespace DesignPatterns.SingletonPattrens
{
    /// <summary>
    /// 锁定单例模式，保证了唯一性，但是每次活动单例都要独占，有性能瓶颈
    /// </summary>
    public class LockSingleton
    {
        private static LockSingleton instance;
        private static readonly object locker = new object();
        private LockSingleton() { }
        public static LockSingleton getInstance()
        {
            lock (locker)
            {
                if (instance == null)
                {
                    instance = new LockSingleton();
                }
            }
            return instance;
        }
    }
}
